home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / surfsrc3.zip / NORMALIZ.INC < prev    next >
Text File  |  1991-09-25  |  2KB  |  73 lines

  1. { SETNORMAL and NORMALIZE were written by Joseph Mackey }
  2. { Variables shared between NORMALIZE and SETNORMAL: }
  3. var Xfactor, Yfactor:   real;    { factors for XYadjust }
  4.  
  5. function SETNORMAL (Xfotran,Yfotran: real; var XYmax: real): boolean;
  6.  
  7. { Set up for normalize procedure }
  8.  
  9. var
  10.   i: word;                        {counter for traversing trans arrays}
  11.   Xmin,Ymin,Xmax,Ymax: real;      {minimum and maximum x & y values}
  12.  
  13. begin
  14. {$ifdef BIGMEM}
  15. with ptrd^ do with ptre^ do
  16. begin
  17. {$endif}
  18.  
  19.   Setnormal := TRUE;
  20.   Xmax:=-99999.0;
  21.   Xmin:=99999.0;
  22.   Ymax:=-9999.0;
  23.   Ymin:=99999.0;
  24.   XYmax:=-99999.0;
  25.  
  26.   if (XYadjust > 1.0) then begin
  27.     Xfactor := 1.0;
  28.     Yfactor := 1.0 / XYadjust;
  29.   end else begin
  30.     Xfactor := XYadjust;
  31.     Yfactor := 1.0;
  32.   end;
  33.  
  34.   for i:=1 to Nnodes do begin
  35.     if Xtran[i]>Xmax then
  36.       Xmax:=Xtran[i];
  37.     if Xtran[i]<Xmin then
  38.       Xmin:=Xtran[i];
  39.     if Ytran[i]>Ymax then
  40.       Ymax:=Ytran[i];
  41.     if Ytran[i]<Ymin then
  42.       Ymin:=Ytran[i];
  43.   end;
  44.  
  45.   if (Xfotran>Xmax) or (Xfotran<Xmin) or (Xfotran>Ymax) or (Yfotran<Ymin) then
  46.     Setnormal := FALSE;
  47.  
  48.  
  49.   for i:=1 to Nnodes do begin
  50.     if abs(Xtran[i]-Xfotran)>XYmax then
  51.       XYmax:=abs(Xtran[i]-Xfotran);
  52.     if abs(Ytran[i]-Yfotran)>XYmax then
  53.       XYmax:=abs(Ytran[i]-Yfotran);
  54.   end;
  55. {$ifdef BIGMEM}
  56. end; {with}
  57. {$endif}
  58. end; { function Setnormal }
  59.  
  60. procedure NORMALIZE (var Xtr, Ytr: real; Xfotran, Yfotran, XYmax: real);
  61.  
  62.     {procedure takes 2-D nodes, scales and offsets them relative to the
  63.      focal point now offset to the center of the screen}
  64.  
  65. begin
  66. {   Note: 0.35333 is 0.5 * (6.625 / 9.375).
  67.     9.375 is X dimension of screen in inches; 6.625 is Y dimension. }
  68.     Xtr := (Gxmax+Gxmin) div 2 -
  69.         round((Xfotran-Xtr)*0.35333*(Gxmax-Gxmin)*Magnify*Xfactor/XYmax);
  70.     Ytr := (Gymax+Gymin) div 2 +
  71.         round((Yfotran-Ytr)*0.5*(Gymax-Gymin)*Magnify*Yfactor/XYmax);
  72. end; { procedure NORMALIZE }
  73.